def test1():
    a = 10
    print('test1开始执行')
    print(f'test1内部变量a的值是{a}')
    def test2():
        nonlocal a
        a = 100
        print('test2开始执行')
        print(f'test2内部变量a的值是{a}')
    test2()
    print(f'test1内部变量a的值是{a}')

test1()